Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Adriano Fabri 469 posts 1633 karma points
    Mar 05, 2014 @ 15:11
    Adriano Fabri
    0

    [URGENT] I cannot retrieve properties value of unpublished node

    Hello,
    I must display a list of unpublished nodes.

    My actual code is:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    <table border="0" cellspacing="0" cellpadding="5">
    <tr style="background-color: #CCC">
    <th>Numero</th>
    <th>Node name</th>
    <th>Update date</th>
    </tr>
    @{
    var node = uComponents.Core.uQuery.GetDocument(2364);
    foreach (var item in node.Children)
    {
    if ([email protected])
    {
    var numero = @item.getProperty("numero").Value.ToString();
    <tr style="background-color: #DDD">
    <td>@numero</td>
    <td>@item.Text</td>
    <td>@item.UpdateDate</td>
    </tr>
    }
    }
    }
    </table>

    When I try to display the result, I receive this error:
    Error loading Razor Script TabellaArchivioAlbo.cshtml
    Object reference not set to an instance of an object.

    I tried to display the umbraco properties and it work properly, but if i try to access node custom properties (like "numero") I always receive the above error.

    Can anybody help me?
    Thank you in advance
    Adriano

  • Adriano Fabri 469 posts 1633 karma points
    Mar 05, 2014 @ 15:36
    Adriano Fabri
    100

    Solved!!!

    I searched all properties and retrieve only the ones I need.

    @foreach(var prop in doc.getProperties)
       {
        var alias prop.PropertyType.Alias;
        if ((alias=="numero"|(alias=="del"|(alias=="oggetto"))
        {
         var propValue prop.Value;
         <td>@propValue</td>
        }
       }

     It work correctly.

Please Sign in or register to post replies

Write your reply to:

Draft